define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=ForumProxy;
function ForumProxy(){
	function forumSubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/forum';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function loginForumRq(union,loginName,password,success,ignoreError){
        var request=new JlnRequest();
        request.func='loginForum';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['loginName']=loginName;
		request.params['p']=password;

		if (union == true) {
	        request.svr = 'forum';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.loginForumRequest=function(loginName,password,success,ignoreError){
       var request= loginForumRq(true,loginName,password,success,ignoreError);
       return request;
    }
	this.loginForum=function(loginName,password,success,ignoreError){
       var request= loginForumRq(false,loginName,password,success,ignoreError);
       forumSubmit(request, success, ignoreError);

    }

	function logoutRq(union,success,ignoreError){
        var request=new JlnRequest();
        request.func='logout';
        request.token = Base.localStorage.getItem('request_token');
		
		if (union == true) {
	        request.svr = 'forum';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.logoutRequest=function(success,ignoreError){
       var request= logoutRq(true,success,ignoreError);
       return request;
    }
	this.logout=function(success,ignoreError){
       var request= logoutRq(false,success,ignoreError);
       forumSubmit(request, success, ignoreError);

    }
}

});
